package com.jsp.controller.usercontroller;

import com.jsp.entity.User;
import com.jsp.mapper.impl.UserMapperImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Objects;

@WebServlet(name = "UserLogoutServlet", value = "/userLogout")
//登出
public class UserLogoutServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)  {

    }
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) {
        Cookie username = new Cookie("username", null);
        Cookie password = new Cookie("password", null);
        username.setMaxAge(0);
        password.setMaxAge(0);
        response.setStatus(302);
        response.addCookie(username);
        response.addCookie(password);
        response.setHeader("Location","http://localhost:8080/jsp_demo/index.jsp");
    }
}
